package FrameWork.Executor;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

public class EventLoopThreadFactory implements ThreadFactory{

    private static final String PoolPrefix = "EventLoopGroup-";
    private static final String ThreadPrefix = "-Thread-";
    private static AtomicInteger poolCounter = new AtomicInteger(0);
    private AtomicInteger threadCounter = new AtomicInteger(0);
    private int poolIdx = poolCounter.incrementAndGet();

    EventLoopThreadFactory(){

    }

    @Override
    public Thread newThread(Runnable r) {
        String name = PoolPrefix+poolIdx+ThreadPrefix+threadCounter.incrementAndGet();
        return new EventLoopThread(r,name);
    }


}
